home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 February: Tool Chest / Dev.CD Feb 95 / Dev.CD Feb 95.toast / Sample Code / Newton Sample Code 1.2 / Views / Wrap It Up-3 / Wrap It Up.text < prev    next >
Encoding:
Text File  |  1994-07-08  |  3.6 KB  |  144 lines  |  [TEXT/MPS ]

  1.  
  2. // ---- End Project Data ----
  3.  
  4.  
  5. // ---- File Wrap It Up.t ----
  6.  
  7. // Before Script for "paragraphApp"
  8. // Copyright © 1994 by Apple Computer, Inc.  All rights reserved.
  9.  
  10. paragraphApp :=
  11.    {title: "Wrap It Up",
  12.     viewBounds: {top: 0, left: 0, right: 240, bottom: 336},
  13.     viewSetupFormScript:
  14.       func()
  15.       begin
  16.           constant kMaxWidth := 240;
  17.           constant kMaxHeight := 336;
  18.       
  19.           local b := GetAppParams();
  20.       
  21.           self.viewBounds := RelBounds(b.appAreaLeft, b.appAreaTop,
  22.                                                   Min(b.appAreaWidth, kMaxWidth),
  23.                                                   Min(b.appAreaHeight, kMaxHeight)
  24.                                               );
  25.       end,
  26.     _proto: protoApp,
  27.     debug: "paragraphApp"
  28.    };
  29.  
  30. _view000 := /* child of paragraphApp */
  31.    {viewFlags: 33,
  32.     viewFormat: 337,
  33.     viewBounds: {left: 9, top: 25, right: 231, bottom: 159},
  34.     viewSetupChildrenScript:
  35.       func()
  36.       begin
  37.       stepchildren := EnsureInternal(stepchildren);
  38.       end,
  39.     viewclass: 77
  40.    };
  41.  
  42. theParagraph := /* child of _view000 */
  43.    {viewFlags: 134217737,
  44.     viewFormat: 337,
  45.     viewFont: userFont12,
  46.     viewBounds: {left: 9, top: 9, right: 209, bottom: 105}
  47.     ,
  48.     text: "Word",
  49.     viewJustify: 0,
  50.     viewclass: 81,
  51.     debug: "theParagraph"
  52.    };
  53. // View theParagraph is declared to paragraphApp
  54.  
  55. // After Script for "theParagraph"
  56. thisView := theParagraph;
  57. thisView.viewLineSpacing := nil;
  58. // Make sure this slot is set here so it doesn't inherit
  59. // GetRoot() has a viewLineSpacing slot!
  60.  
  61.  
  62.  
  63.  
  64.  
  65. addAbove := /* child of paragraphApp */
  66.    {text: "Add word above",
  67.     buttonClickScript:
  68.       func()
  69.       begin
  70.          SetValue(theParagraph, 'text, theParagraph.text && GetRandomWord(0, 20));
  71.          SetValue(theParagraph, 'viewBounds, theParagraph.viewBounds);
  72.       
  73.          // the second SetValue is needed to tweak the clParagraphView into
  74.          // updating an internal cache.  It's a workarond for a clParagraphView
  75.          // bug.  The SetValue doesn't necessarily have to be for viewBounds.
  76.       end,
  77.     viewBounds: {left: 10, top: 170, right: 110, bottom: 182},
  78.     _proto: protoTextButton,
  79.     debug: "addAbove"
  80.    };
  81.  
  82.  
  83.  
  84. addBelow := /* child of paragraphApp */
  85.    {text: "Add word below",
  86.     buttonClickScript:
  87.       func()
  88.       begin
  89.          SetValue(anotherParagraph, 'text, anotherParagraph.text && GetRandomWord(0, 20));
  90.       end,
  91.     viewBounds: {left: 130, top: 170, right: 230, bottom: 182},
  92.     _proto: protoTextButton,
  93.     debug: "addBelow"
  94.    };
  95.  
  96.  
  97.  
  98. anotherParagraph := /* child of paragraphApp */
  99.    {viewFlags: 6657,
  100.     viewFormat: 337,
  101.     viewFont: userFont12,
  102.     viewBounds: {left: 17, top: 193, right: 223, bottom: 209},
  103.     text: "Word",
  104.     viewJustify: 0,
  105.     viewChangedScript:
  106.       func(slot, view)
  107.       begin
  108.          if slot = 'text and view = self then
  109.             :AdjustHeight();
  110.       end,
  111.     AdjustHeight:
  112.       func()
  113.       begin
  114.          local width := viewBounds.right - viewBounds.left;
  115.          local height := call kSimpleTextHeightFunc with (text, width, viewFont);
  116.       
  117.          if viewBounds.top + height <> viewBounds.bottom then
  118.              begin
  119.                  local newBounds := DeepClone(viewBounds);
  120.                  newBounds.bottom := newBounds.top + height;
  121.                  SetValue(self, 'viewBounds, newBounds);
  122.              end;
  123.       end;,
  124.     viewclass: 81,
  125.     debug: "anotherParagraph"
  126.    };
  127. // View anotherParagraph is declared to paragraphApp
  128.  
  129. // After Script for "anotherParagraph"
  130. thisView := anotherParagraph;
  131. thisView.viewLineSpacing := nil;
  132.  
  133. // Make sure this slot is set here so it doesn't inherit
  134. // GetRoot() has a viewLineSpacing slot!
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142. // ---- Beginning of section for non used Layout files ----
  143.  
  144. // End of output